﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace PlaceOrder_Server.Converters
{
    public class UserStatusConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {

          

            int status = (int)value;
            return status == 0 ? "离线" : (status == 1 ? "在线" : "");
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // 判断是否是用户触发的更改
            if (value != null && value is string statusString)
            {
                if (statusString == "离线")
                    return 0;
                else if (statusString == "在线")
                    return 1;
            }

            // 如果不是用户触发的更改，则返回原始值
            return value;
        }
    }
}
